package test3_10;

public class Test3_twoArrayElementsAreSwapped {
    public static void main(String[] args) {
        /*
        两个数组元素交换 {1,2,3,4},{5,6,7,8} -> {5,6,7,8},{1,2,3,4}
         */
        int[] array1 = {1, 2, 3, 4};
        int[] array2 = {5, 6, 7, 8};
        int t = 0;
        for (int i = 0; i < array1.length; i++) {
            t = array1[i];
            array1[i] = array2[i];
            array2[i] = t;
        }
        for (int x : array1) {
            System.out.print(x + " ");
        }
        System.out.println();
        for (int x : array2) {
            System.out.print(x + " ");
        }
    }
}
